using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Objects;
using BAL;

public partial class Admin_UCControls_UCDuyet_ThongTinThe : System.Web.UI.UserControl
{
    public static Duyet item;
    public static string strPath;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            DanhSachChoDuyet itemChoDuyet = new DanhSachChoDuyet();
            itemChoDuyet = (DanhSachChoDuyet)Session["ItemDuyet"];

            item = new Duyet();

            if (itemChoDuyet != null)
            {
                item = BALDuyet.GetById(itemChoDuyet.Id);
            }
           
            if (item != null)
            {
                DangKy itemDangKy = new DangKy();
                itemDangKy = BALDangKy.GetById(item.IdDangKy);
                lblNgayDangKy.Text = itemDangKy.NgayDangKy.ToShortDateString();
                lblSoLuong.Text = itemDangKy.SoLuong.ToString();
                lblMaThanhToan.Text = itemDangKy.MaThanhToan.ToString();
                //lblNgayNhanThe.Text = itemDangKy.NgayNhanThe.ToShortDateString();
                //lblHetHan.Text = itemDangKy.NgayHetHan.ToShortDateString();

                GetLoaiThe(itemDangKy.IdLoaiThe);
                GetMauThe(itemDangKy.IdMauThe);
                GetMenhGia(itemDangKy.IdMenhGia);
                GetMenhGiaKhac(itemDangKy.IdMenhGiaKhac);

                double thanhtien = Convert.ToInt64(lblSoLuong.Text) * Convert.ToInt64(lblMenhGia.Text);
                lblThanhTien.Text = thanhtien.ToString("0,000.##") + " VND";

            }
        }
    }

    public void GetLoaiThe(int Id)
    {
        LoaiThe ItemLoaiThe = new LoaiThe();
        ItemLoaiThe = BALLoaiThe.GeById(Id);
        lblLoaiThe.Text = ItemLoaiThe.LoaiTheDK.ToString();

    }

    public void GetMauThe(int Id)
    {
        MauThe ItemMauThe = new MauThe();
        ItemMauThe = BALMauThe.GetById(Id);
        lblMauThe.ImageUrl = PathImage() + ItemMauThe.DuongDan.ToString();

        ChuDe ItemChuDe = new ChuDe();
        ItemChuDe = BALChuDe.GetByIdChuDe(ItemMauThe.IdChuDe);
        lblChuDe.Text = ItemChuDe.TenChuDe.ToString();

    }


    public void GetMenhGia(int Id)
    {
        if (Id > 0)
        {
            MenhGia ItemMenhGia = new MenhGia();
            ItemMenhGia = BALMenhGia.GetById(Id);
            lblMenhGia.Text = ItemMenhGia.LoaiMenhGia.ToString();
        }
    }
    
    public void GetMenhGiaKhac(int Id)
    {
        if (Id > 0)
        {
            MenhGiaKhac ItemMenhGiaKhac = new MenhGiaKhac();
            ItemMenhGiaKhac = BALMenhGiaKhac.GetById(Id);
            lblMenhGia.Text = ItemMenhGiaKhac.LoaiMenhGia.ToString();
        }
    }

    public string PathImage()
    {
        return strPath = "~/images/Generic Card/MauThe/";
    }
}
